/*
 * @Description: 
 * @Author: fhw
 * @Date: 2023-01-10 10:43:27
 */
import { ApiProperty } from "@nestjs/swagger";
import { GroupChatRecord } from "src/chat-record/entities/group-chat-record.entity";
import { UserChatRecord } from "src/chat-record/entities/user-chat-record.entity";
import { ChatUser } from "src/chat_user/entities/chat_user.entity";
import { GroupChat } from "src/group-chat/entities/group-chat.entity";
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";

/*
 * @Description: 
 * @Author: fhw
 * @Date: 2023-01-10 10:43:27
 */
@Entity('history-session')
export class HistorySession {
    @ApiProperty({ example: 'id', description: 'id' })
    @PrimaryGeneratedColumn({
        type: 'int',
        comment: 'id',
    })
    id: number;

    @ApiProperty({ example: 'userId', description: '用户id' })
    @Column({
        type: 'int',
        comment: '用户id',
    })
    userId: number;
    @ManyToOne(() => ChatUser, (user) => user.id, { eager: true })
    @JoinColumn({ name: 'userId' })
    user: ChatUser

    @ApiProperty({ example: 'historicalUserSessionsId', description: '历史用户会话ID,用户id或群聊' })
    @Column({
        type: 'varchar',
        comment: '历史用户会话ID,用户id或群聊',
    })
    historicalUserSessionsId: string;

    @ApiProperty({ example: 'date', description: '创建时间' })
    @CreateDateColumn({
        type: 'datetime',
        comment: '创建时间',
    })
    createDate: string;

    @ApiProperty({ example: 'updateDate', description: '更新时间' })
    @UpdateDateColumn({
        type: 'datetime',
        comment: '更新时间',
    })
    updateDate: string;
    /** 最新消息Id */
    @ApiProperty({ example: 'latestNewsId', description: '最新消息Id' })
    @Column({
        type: 'tinyint',
        comment: '最新消息Id',
        nullable: true
    })
    latestNewsId: number
    @ManyToOne(() => UserChatRecord, (latestNews) => latestNews.id, { nullable: true, eager: true })
    @JoinColumn({ name: 'latestNewsId' })
    latestNews: UserChatRecord
    

    /** 免打扰，0：开启，1：关闭 */
    @ApiProperty({ example: 'doNotDisturb', description: '免打扰，0：开启，1：关闭' })
    @Column({
        type: 'enum',
        comment: '免打扰，0：开启，1：关闭',
        enum: [0, 1],
        nullable: true,
        default: 1
    })
    doNotDisturb: string
}